package acom.dhy.qigsaw2test.qigsaw

import acom.dhy.qigsaw2test.App
import android.content.Context
import android.widget.Toast
import com.dhy.qigsaw.splash.data.TestCase
import java.util.*

interface CrossService {
    fun showTip(context: Context)
}

fun loadCrossService(): CrossService? {
    val services = ServiceLoader.load(CrossService::class.java)
    val iterator = services.iterator()
    for (crossService in iterator) {
        return crossService
    }
    return null
}

fun crossServiceShowTip(context: Context) {
    val service = loadCrossService()
    if (service != null) {
        service.showTip(context)
    } else {
        App.testCases[TestCase.CROSS] = false
        Toast.makeText(context, "no crossService ShowTip", Toast.LENGTH_SHORT).show()
    }
    println("crossServiceShowTip service $service")
}